package com.tuozixuan.mapstruct.controller;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.tuozixuan.mapstruct.dto.UserDto;
import com.tuozixuan.mapstruct.mapping.UserMapper;
import com.tuozixuan.mapstruct.model.User;

@Controller
public class HomeController {
    
    @Autowired
    private UserMapper userMapper;
    
    @ResponseBody
    @RequestMapping("/")
    public String index() {
        User user = new User();
        user.setId(820225435405205504L);
        user.setName("zhangsan");
        user.setName1("name1");
        user.setAge(12);
        user.setBirthDate(new Date());
        user.setCreateDate(new Date());
        UserDto userDto = userMapper.toUserDto(user);
        
        User user1 = userMapper.toUser(userDto);
        
//        UserDto userDto = UserMapper.INSTANCE.toUserDto(user);
        return "ok";
    }
}
